package com.itheima.utils;

import java.util.Collection;
import java.util.Map;

/**
 * @ClassName: CommonUtil
 * @Description:
 * @author: Yrd
 * @date: 2021-10-29 18:45
 */
public class CommonUtil {

    /**
     *
     * @Title : isNullObj
     * @Description : 判断对象是否为null,数组size=0,字符串length=0

     * @param obj
     * @return boolean
     *
     * @user : Yrd
     * @date : 2021-10-29 19:20
     */
    private static boolean isNullObj(Object obj){
        if (obj == null){
            return true;
        }

        if (String.class.isInstance(obj)){
            return isEmpty((String) obj);
        }else if (Collection.class.isInstance(obj)){
            return ((Collection) obj).size() == 0;
        }else if (Map.class.isInstance(obj)){
            return ((Map) obj).size() == 0;
        }else {
            return obj == null;
        }
    }

    /**
     *
     * @Title : isEmpty
     * @Description : 判断字符串是否为null,字符串length=0

     * @param str
     * @return boolean
     *
     * @user : Yrd
     * @date : 2021-10-29 19:21
     */
    public static boolean isEmpty(String str){
        return str == null || str.length() == 0;
    }

    /**
     *
     * @Title : isEquals
     * @Description : 判断str1和str2是否相等

     * @param str1
     * @param str2
     * @return boolean
     *
     * @user : Yrd
     * @date : 2021-10-29 19:25
     */
    public static boolean isEquals(String str1,String str2){
        if (str1 == null && str2 == null){
            return true;
        }else {
            return str1 != null && str2 != null ? str1.equals(str2):false;
        }
    }
}
